<?php
//模块名_控制名
class Plan_PlanUsageDetailController extends Zend_Controller_Action
{
	
	private $planUsageDetail ;
	
	public function preDispatch(){
		$this->planUsageDetail = new Plan_Service_PlanUsageDetail();
		$this->tplDirectory = "plan/usageDetail/";	//控制对应模板目录
	}
	
	public function indexAction(){
		$currency=Common_Service_Currency::getByCondition(array());//货币
		$this->view->currency=$currency;
		echo Cff::renderTpl($this->tplDirectory."index.tpl","layout");	
    }
    
	/**
	*查询套餐
	*@param page,pageSize
	*return json
	*/
	public function listAction(){
		$intpage=$this->_request->getParam('page',1);
		$pageSize=$this->_request->getParam('pageSize');
		$type=$this->_request->getParam('billtype'); //计费类型
		$customer_id=$this->_request->getParam('customer_id'); //计费类型
		$intpage = ($intpage<1)?1:$intpage;
		$condition=array(			
			'type'=>$type,
			'customer_id'=>$customer_id,
		);
		
		$count=$this->planUsageDetail->getByCondition($condition,'count(*)','',0,0);
		$data=array(
			'count'=>0,
			'ask'=>0
			);
		if($count>0){
			$result=$this->planUsageDetail->getByCondition($condition,'*',array('pud_id desc'),$pageSize,$intpage);
			$data=array(
				'zfversion'=>Zend_Version::VERSION,
				'count'=>$count,
				'result'=>$result,
				'ask'=>1
			);
		}
		die(Zend_Json::encode($data));
	}
    
}